#include "startthread.h"

StartThread::StartThread(QObject *parent) : QObject(parent)
{

}

void StartThread::startThread()
{
    //开启服务器
    TcpServer tcpServer;

    tcpServer.moveToThread(&tcpServerThread);
    QObject::connect(&tcpServerThread,SIGNAL(started()),&tcpServer,SLOT(start()));
    tcpServerThread.start();


    SQLiteThread *sqliteThread=nullptr;
    sqliteThread = new SQLiteThread("conn_1",group_number,this);
//    sqliteThread->moveToThread(&threadOne);

//    threadOne.start();

    tcpServerThread.start();
    sqliteThread->start();

    connect(this,&StartThread::destroyed,this,[=](){
        tcpServerThread.quit();
        tcpServerThread.wait();
        tcpServerThread.deleteLater();

        sqliteThread->quit();
        sqliteThread->wait();
        sqliteThread->deleteLater();

      });

}
